import time
import random


# 随机道家修持工具类
class UltimateTaoistCharm:
    def __init__(self):
        self.energy_level = 0
        self.five_elements = {"木": 0, "火": 0, "土": 0, "金": 0, "水": 0}
        self.bagua = {"乾": "天", "坤": "地", "震": "雷", "巽": "风", "坎": "水", "离": "火", "艮": "山", "兑": "泽"}
        self.charm = []
        self.meridians = ["手太阴肺经", "手阳明大肠经", "足阳明胃经", "足太阴脾经", "手少阴心经", "手太阳小肠经",
                          "足太阳膀胱经", "足少阴肾经", "手厥阴心包经", "手少阳三焦经", "足少阳胆经", "足厥阴肝经"]
        self.dantian = {"下丹田": "精", "中丹田": "炁", "上丹田": "神"}
        self.zhou_tian = ["小周天", "大周天"]
        self.taoist_gods = ["三清", "玉皇", "太上老君", "文昌帝君", "财神"]
        self.taoist_rituals = ["斋醮", "符箓", "炼丹", "诵经", "打坐"]

    def purify_mind(self):
        # 净心凝神
        print("净心凝神中...")
        time.sleep(2)
        print("意守丹田，感炁机流转，与天地共鸣。")
        time.sleep(2)

    def purify_tools(self):
        # 净笔净纸
        print("净笔净纸中...")
        time.sleep(2)
        print("笔净如心，纸净如镜，天地借法，愿力加持。")
        time.sleep(2)

    def draw_charm(self):
        # 绘符咒，合八卦之理
        print("绘符咒中...")
        for trigram, element in self.bagua.items():
            self.charm.append((trigram, element))
            print(f"{trigram}（{element}） ", end="", flush=True)
            time.sleep(1)
        print("\n符咒已成，与天地通。")

    def absorb_five_elements(self):
        # 纳五行之炁，合天地之机
        print("纳五行之炁...")
        for element, value in self.five_elements.items():
            energy = random.randint(1, 10)
            self.five_elements[element] += energy
            self.energy_level += energy
            print(
                f"纳 {element} 炁: +{energy} | 当前 {element} 炁量: {self.five_elements[element]} | 总炁量: {self.energy_level}")
            time.sleep(1)
        print("五行之炁已纳，炁机充盈。")

    def resonate_bagua(self):
        # 八卦共振，合宇宙之律
        print("启八卦共振...")
        for trigram, element in self.charm:
            resonance = random.randint(5, 15)
            self.energy_level += resonance
            print(f"八卦符 {trigram}（{element}） 共振: +{resonance} | 当前炁量: {self.energy_level}")
            time.sleep(1)
        print("八卦共振已成，与天地合。")

    def refine_inner_alchemy(self):
        # 炼内丹，化炁为神
        print("启内丹术，炼炁化神...")
        for dantian, essence in self.dantian.items():
            print(f"炼 {dantian}（{essence}），炁机升华...")
            self.energy_level *= 1.2  # 每炼一丹，炁量提升二成
            time.sleep(2)
        print(f"内丹已成，炁量升华: {self.energy_level:.2f}")

    def circulate_meridians(self):
        # 通经络，炁行周天
        print("通经络，炁行周天...")
        for meridian in self.meridians:
            print(f"通 {meridian}，炁机流转...")
            self.energy_level += random.randint(5, 10)
            time.sleep(1)
        print("经络已通，炁行周天。")

    def run_zhou_tian(self):
        # 运行周天，炁机循环
        print("运行周天，炁机循环...")
        for cycle in self.zhou_tian:
            print(f"运行 {cycle}，炁机循环...")
            self.energy_level *= 1.1  # 每运行一周天，炁量提升一成
            time.sleep(2)
        print(f"周天已成，炁机循环。当前炁量: {self.energy_level:.2f}")

    def invoke_taoist_gods(self):
        # 请神护法，加持愿力
        print("请神护法，加持愿力...")
        for god in self.taoist_gods:
            print(f"请 {god} 护法，愿力加持...")
            self.energy_level += random.randint(10, 20)
            time.sleep(2)
        print("神明已请，愿力加持。")

    def perform_taoist_rituals(self):
        # 行道教仪式，显化愿力
        print("行道教仪式，显化愿力...")
        for ritual in self.taoist_rituals:
            print(f"行 {ritual}，愿力显化...")
            self.energy_level += random.randint(5, 15)
            time.sleep(2)
        print("仪式已成，愿力显化。")

    def manifest_energy(self):
        # 显化炁机，成愿于天
        if self.energy_level >= 500:
            print("&#127775; 符咒显化，愿力已注宇宙 &#127775;")
            print("汝之愿力，已与天地共鸣，显化于现实。")
        else:
            print("&#128167; 炁量不足，需重绘符咒，再纳天地之炁。 &#128167;")


def ultimate_taoist_charm():
    print("&#127775; 启玄门符咒真诀 &#127775;")
    charm = UltimateTaoistCharm()
    print("1. 净心凝神...")
    charm.purify_mind()
    time.sleep(2)
    print("2. 净笔净纸...")
    charm.purify_tools()
    time.sleep(2)
    print("3. 绘八卦符咒，通天地之炁...")
    charm.draw_charm()
    time.sleep(3)
    print("4. 纳五行之炁，合天地之机...")
    charm.absorb_five_elements()
    time.sleep(3)
    print("5. 启八卦共振，合宇宙之律...")
    charm.resonate_bagua()
    time.sleep(3)
    print("6. 启内丹术，炼炁化神...")
    charm.refine_inner_alchemy()
    time.sleep(3)
    print("7. 通经络，炁行周天...")
    charm.circulate_meridians()
    time.sleep(3)
    print("8. 运行周天，炁机循环...")
    charm.run_zhou_tian()
    time.sleep(3)
    print("9. 请神护法，加持愿力...")
    charm.invoke_taoist_gods()
    time.sleep(3)
    print("10. 行道教仪式，显化愿力...")
    charm.perform_taoist_rituals()
    time.sleep(3)
    print("11. 显化炁机，成愿于天...")
    charm.manifest_energy()
    print("&#127775; 玄门符咒真诀已成 &#127775;")


# 运行演示
ultimate_taoist_charm()